package com.baidu.iit.hib;

import java.util.Map;

import org.hibernate.Session;
import org.hibernate.engine.EntityEntry;
import org.hibernate.event.EventSource;

/**
 * Hibernate测试相关工具类.
 * 
 * @author GuoLin
 *
 */
public abstract class HibernateUtils {

	/**
	 * 获取Session中的元素映射.
	 * @param session Hibernate Session
	 * @return 一个Map，key是实体，值是EntityEntry对象，其中包含很多有用的信息
	 */
	@SuppressWarnings("unchecked")
	public static Map<Object, EntityEntry> getEntityFromSession(Session session) {
		EventSource source = (EventSource)session;
		return source.getPersistenceContext().getEntityEntries();
	}
}
